<!DOCTYPE html>
<!--
Copyright 2012 The Polymer Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<html>
  <head>
    <title></title>
    <script src="lib/loader.js"></script>
    <style>
      div, g-A, g-B {
        display: block;
        border: 1px dotted red;
        margin: 8px;
        padding: 8px;
      }
    </style>
    <script>
      change = function() {
        A = $("g-A");
        A.webkitCreateShadowRoot().appendChild($('template#A').content);
        //
        B = A.webkitShadowRoot.querySelector('g-B');
        B.webkitCreateShadowRoot().appendChild($('template#B').content);
        //
        A.appendChild(document.createElement('span')).textContent = 'ADDED!!';
        A.appendChild(document.createTextNode('TEXT!!'));
      }
    </script>
  </head>
  <body onload="change()">
      <g-A><span id="a1">Where am I?</span></g-A>

      <template id="A">[A->]<g-B><content></content></g-B>[<-A]</template>
      <template id="B">[B->][<content></content>][<-B]</template>

      <hr/>

      Expected output (also, see console):

      <div>[A-&gt;]
        <div>[B-&gt;][<span id="a1">Where am I?ADDED!!TEXT!!</span>][&lt;-B]</div>
      [&lt;-A]</div>

</body>
</html>
